package com.neusoft.yuejian_01.activity;

import android.content.Context;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.base.BaseActivity;
import com.neusoft.yuejian_01.javabean.MatchRegBean;
import com.neusoft.yuejian_01.listener.RetrofitListener;
import com.neusoft.yuejian_01.model.MatchModel;

public class MatchOrderActivity extends BaseActivity implements RetrofitListener {
    private TextView matchuserphoneView;
    private TextView matchpriceView;
    private TextView matchtimeView;
    private TextView matchaddressView;
    private TextView matchnameView;
    private TextView matchuserView;
    private ImageView matchpass;
    protected Context context;
    private ImageButton button_back;//返回按钮
    private int m_id;

     protected void initView() {
         setContentView(R.layout.activity_match_order);
        matchuserphoneView = (TextView) findViewById(R.id.matchphone);
        matchpriceView = (TextView) findViewById(R.id.matchprice);
        matchnameView = (TextView) findViewById(R.id.matchname);
        matchuserView = (TextView) findViewById(R.id.matchusername);
        matchtimeView = (TextView) findViewById(R.id.matchtime);
        matchaddressView = (TextView) findViewById(R.id.matchaddress);
        button_back = (ImageButton) findViewById(R.id.button_back);
        matchpass = (ImageView) findViewById(R.id.matchpass);
    }
     protected void initEvents() {
        button_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
     protected void initData() {
        m_id = getIntent().getIntExtra("m_id", -1);
        MatchModel matchModel = new MatchModel();
        matchModel.getMatchRegistration(String.valueOf(getUser_id()), String.valueOf(m_id), this);
    }
    @Override
    public void onSuccess(Object object, int flag) {
        MatchRegBean matchRegBean =  (MatchRegBean)object;
        matchuserphoneView.setText(matchRegBean.getU_phone());
        matchpriceView.setText(String.valueOf(matchRegBean.getM_price()));
        matchuserView.setText(matchRegBean.getU_name());
        matchnameView.setText(matchRegBean.getM_name());
        matchtimeView.setText(matchRegBean.getM_time());
        matchaddressView.setText(matchRegBean.getM_address());
        if (matchRegBean.getMn_pass().equals("1")){
            //已通过审核
            matchpass.setImageResource(R.drawable.ic_checkeds);
        }
        else {
            //未通过审核
            matchpass.setImageResource(R.drawable.ic_checks);
        }
    }
    @Override
    public void onFail() {
        Toast.makeText(this,"fail",Toast.LENGTH_LONG).show();
    }
}
